﻿<#include "/tags/utils.ftl">
<#include "/tags/commentTag.ftl">
<#include "/tags/commentBoxTag.ftl">
<#include "/tags/commentPackageTag.ftl">
<#include "/tags/updatedSinceTag.ftl">

<#macro wall wallActivities wallOwner>
	<#list wallActivities as activity>
		<div class="wallActivity">
    		<#if activity.component == "USER_THOUGHT">			
		    	<a class="wallUserAvatar" href="${activity.postOwner}">
		    		<img src="${activity.postOwnerAvatar}" width="50"/>
		    	</a>
	    	<#else>
		    	<a class="wallUserAvatar" href="${activity.componentOwner}">
		    		<img src="${activity.componentOwnerAvatar}" width="50"/>
		    	</a>
	    	</#if>
	        <div class="wallActivityContainer">
	        	<#assign actionText = buildActivityText(activity.componentOwner, activity.componentOwnerName activity.action, activity.component, activity.componentId, activity.componentTitle, activity.componentLink) />
	        	<div class="wallActivityContent">
	        		<#if activity.component == "USER_THOUGHT">
		        		<p>
	        				<#if activity.componentOwner != activity.postOwner>
			        			<a class='user' href='${rc.contextPath}/${activity.postOwner}'>${activity.postOwnerName}</a> viết lên tường của <a class='user' href='/${activity.componentOwner}'>${activity.componentOwnerName}</a>
			        			<#if data.userInSession == activity.componentOwner || data.userInSession == activity.postOwner>
			        				<a class="postDelete" rel="POST_${activity.componentId}"></a>
			        			</#if>
			        			<br/>${actionText}
			        		<#else>
			        			<a class='user' href='${rc.contextPath}/${activity.postOwner}'>${activity.postOwnerName}</a> ${actionText}
			        			<#if data.userInSession == activity.componentOwner || data.userInSession == activity.postOwner>
			        				<a class="postDelete" rel="POST_${activity.componentId}"></a>
			        			</#if>
			        		</#if>
		        		</p>
			        <#else>
		        		<p><a class='user' href='${rc.contextPath}/${activity.componentOwner}'>${activity.componentOwnerName}</a> ${actionText}</p>
					</#if>
			        <p class="timeLikeComment onWall">
			        	<@updatedSince minutes=activity.updatedSince prefix='page.dashboard.updateSince'/>
			        	<#if activity.likeEnabled>
			        		<#if activity.likeThis>
				        		<span class="like" style="display:none;"><a href="#" rel="${activity.component}__${activity.componentId}"> &bull; Thích</a></span>
					        	<span class="unlike"><a href="#" rel="${activity.component}__${activity.componentId}"> &bull; Bỏ thích</a></span>
				        	<#else>
				        		<span class="like"><a href="#" rel="${activity.component}__${activity.componentId}"> &bull; Thích</a></span>
					        	<span class="unlike" style="display:none;"><a href="#" rel="${activity.component}__${activity.componentId}"> &bull; Bỏ thích</a></span>
			        		</#if>
			        	</#if>
			        	<#if activity.commentEnabled><a href="#" class="show_comment_box"> &bull; Ý kiến</a></#if>
			        </p>
			        <#if activity.likeEnabled && activity.likeCount gt 0>
		        		<#assign likeList = "" />
			        	<#if activity.likeThis>
			        		<#assign likeList = "Bạn" />
			        	</#if>
			        	<#if activity.randomUserLikes??>
			        		<#list activity.randomUserLikes as ul>
			        			<#assign text = buildUserString(ul.username ul.fullName "") />
			        			<#if likeList?has_content>
			        				<#assign likeList = likeList + ", " +text />
			        			<#else>
			        				<#assign likeList = text />
			        			</#if>
			        		</#list>
			        	</#if>
			        	<p class="likeListUser"><a class="entryLikeThisHover" href="#"></a> <span class="like_list">${likeList}<#if activity.likeCount gt 2> và <a class="like_list_link" href="${rc.contextPath}/ajax/userList.html?type=LIKE&component=${activity.component}&componentId=${activity.componentId}&pageId=1">${activity.likeCount - 2} người khác</a></#if> thích điều này.</span></p>
			        <#else>
			        	<p class="likeListUser" style="display:none;"><a href="#" class="entryLikeThisHover"></a> <span class="like_list">Bạn thích điều này.</span></p>
			        </#if>
			    </div>
			    <#if activity.commentEnabled>
				   <@commentsPkg componentId=activity.componentId component=activity.component comments=activity.latestComments commentCount=activity.commentCount entryOwner=activity.componentOwner showSettings="off" />
			    </#if>
	        </div>
	    </div>
	    <#if !activity_has_next>
			<#assign lastItem = activity />
		</#if>
	</#list>
	
	 <#if wallActivities?size == 10>
    	<div id="show_more" class="wallReadmore">
    		<a href="javascript:showMoreActivities('wallOwner=${wallOwner}&lastOrderValue=${lastItem.updateDate}')">Hiển thị các hoạt động cũ hơn</a>
    	</div>
    </#if>
</#macro>